#ifndef _OPEN_YUYV2BMP_H
#define _OPEN_YUYV2BMP_H

#include <fcntl.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>

extern int yuv_to_rgb_pixel(int y, int u, int v);
extern int yuyv_to_rgb(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height);
extern void SaveBmp(const char *filename,unsigned char *rgb,int width,int height);
extern int yuyv2bmp();

typedef struct                       /**** BMP file header structure ****/
{
    unsigned short bftype;
    unsigned int   bfSize;           /* Size of file */
    unsigned short bfReserved1;      /* Reserved */
    unsigned short bfReserved2;      /* ... */
    unsigned int   bfOffBits;        /* Offset to bitmap data */

} BITMAPFILEHEADER;

typedef struct                       /**** BMP file info structure ****/
{
    unsigned int   biSize;           /* Size of info header */
    int            biWidth;          /* Width of image */
    int            biHeight;         /* Height of image */
    unsigned short biPlanes;         /* Number of color planes */
    unsigned short biBitCount;       /* Number of bits per pixel */
    unsigned int   biCompression;    /* Type of compression to use */
    unsigned int   biSizeImage;      /* Size of image data */
    int            biXPelsPerMeter;  /* X pixels per meter */
    int            biYPelsPerMeter;  /* Y pixels per meter */
    unsigned int   biClrUsed;        /* Number of colors used */
    unsigned int   biClrImportant;   /* Number of important colors */
} BITMAPINFOHEADER;

#endif
